package de.uni.muenster.idw2.location.bluetooth.service;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;

/**
 * stores Bluetooth-Hosts with x,y,z coordinates
 * @author Andre Korzen
 *
 */
public class BluetoothHost {

	String bthAdress;
	float bthX;
	float bthY;
	int bthFloor;
	
	public BluetoothHost(){}
	
	public BluetoothHost(String address, float x, float y, int floor){
		this.setBthAdress(address);
		this.setBthX(x);
		this.setBthY(y);
		this.setBthFloor(floor);
	}
	
	/*
	 * reads text-file with hostnames + host-coordinates
	 * example
	 * String, Integer, Integer, Integer
	 * 14:22:33:44:55:66,300,300,1
	 */
	public static ArrayList<BluetoothHost> readAllHosts() throws IOException{
		ArrayList<BluetoothHost> allHosts = new ArrayList<BluetoothHost>();
		FileReader fr = new FileReader("/sdcard/allHosts.txt");
		BufferedReader br = new BufferedReader(fr);
		String zeile = br.readLine();
		while (zeile != null) {
			String[] splittArray = zeile.split(",");
			allHosts.add(new BluetoothHost(splittArray[0], Integer.parseInt(splittArray[1]), Integer.parseInt(splittArray[2]), Integer.parseInt(splittArray[3])));
			zeile = br.readLine();
		}
		br.close();
		return allHosts;
	}

	public void setBthAdress(String bthAdress) {
		this.bthAdress = bthAdress;
	}

	public String getBthAdress() {
		return bthAdress;
	}

	public void setBthX(float bthX) {
		this.bthX = bthX;
	}

	public float getBthX() {
		return bthX;
	}

	public void setBthY(float bthY) {
		this.bthY = bthY;
	}

	public float getBthY() {
		return bthY;
	}

	public void setBthFloor(int bthFloor) {
		this.bthFloor = bthFloor;
	}

	public int getBthFloor() {
		return bthFloor;
	}
}
